
***
*** Paper:		Fear of the dark: How terrorist events affect trust in the long run
*** Authors:	Borghi - Braga - Scervini
*** Dofile:		Run regressions
*** Data:		EVS-WVS, GTD, PWT, and Polity4



****************
*** Preamble ***
****************

clear all

set more off

capture log close

use "maindata.dta", clear 


*** DESCRIPTIVE STATISTICS ***

global  missing      "trust_1000 != . & events_tot_15_25!=. & female!=. & age!=. & age2!=. & employ!=. & educ_index!=. & n_child != . & marstat != . & birth_year != . & int_pol != . & import_relig_dummy != . & gdp_growth != . & polity_15_25 != ."

tab year if $missing
tab birth_year if $missing
bys wave: count if trust_1000 != . & events_tot_15_25 != .
bys wave: count if trust_1000 != . & events_tot_15_25!=. & female!=. & age!=. & age2!=. & employ!=. & educ_index!=. & n_child != . & marstat != . & birth_year != . & int_pol != . & gdp_growth != . & polity_15_25 != .





*** TABLE 1 ***

preserve

    keep if $missing
    replace country_txt = "United Kingdom" if cntcode == 826
    foreach wave in 1 2 3 4 5 6 7 {
        gen wave`wave' = 1 if wave == `wave'
    }
    gen i = 1
    label var i "Obs
    collapse (sum) i (sum) wave*, by(country_txt)
    sort country_txt
    gen n = _n
    listtex n country_txt i wave2 wave3 wave4 wave5 wave6 wave7 , replace missnum(.) rstyle(tabular) type

restore

***** TABLE 2 - DESCRIPTIVE STATISTICS *****

sum     trust events_tot_15_25 /// baseline
        events_kills_15_25 events_kills_10_15_25 events_kills_50_15_25 /// T3
        nkill_15_25 terrindex_15_25 property_15_25 damage_15_25 /// T3
        events_tot_t1 nkill_t1 events_kills_t1 events_kills_10_t1 /// T4
        events_kills_50_t1 property_t1 damage_t1 /// T4
        polity_15_25 /// T5
        domestic_misc_15_25 international_misc_15_25 /// T6
        conflict_15_25 conflict_all /// T7
        events_tot_0_14 events_tot_15_25 events_tot_26plus /// T8
        if $missing

sutex2  trust events_tot_15_25 /// baseline
        events_kills_15_25 events_kills_10_15_25 events_kills_50_15_25 /// T3
        nkill_15_25 terrindex_15_25 property_15_25 damage_15_25 /// T3
        events_tot_t1 nkill_t1 events_kills_t1 events_kills_10_t1 /// T4
        events_kills_50_t1 property_t1 damage_t1 /// T4
        polity_15_25 /// T5
        domestic_misc_15_25 international_misc_15_25 /// T6
        conflict_15_25 conflict_all /// T7
        events_tot_0_14 events_tot_15_25 events_tot_26plus /// T8
        if $missing, varlabel minmax 

preserve
    tab educ_index, gen(educ)
    label var educ1 "Primary educ.\ or less"
    label var educ2 "Secondary educ.\"
    label var educ3 "Tertiary educ.\ or more"
    label var marstat "Married"
    label var int_pol "Interested in politics"
    label var import_relig_dummy "Importance to religion"

    gen age_corr = year - birth_year

    label var age_corr "Age"

	sutex2  female age_corr employ educ1 educ2 educ3 n_child marstat int_pol import_relig_dummy ///
        gdp_growth if $missing, varlabel   minmax
restore




***** FIGURE 1 - TERRORIST EVENTS *****

preserve 
	use "$data/gtd2020.dta", clear
	drop if int_misc==-9
drop region region_txt country
kountry iso3, from(iso3n) geo(undet)
rename GEO region_txt
egen region = group(region_txt)
    tab region_txt
    bys iso3: ereplace region = max(region)
rename region_txt region_aux
gen     region_txt = "Australasia & Oceania" if region == 1 |  region == 8 |  region == 13
replace region_txt = "Central America & Caribbean" if region == 2 |  region == 3
replace region_txt = "Central Asia" if region == 4
replace region_txt = "East Asia" if region == 6
replace region_txt = "Eastern Europe" if region == 7
replace region_txt = "Middle East & North Africa" if region == 10 | region == 20
replace region_txt = "North America" if region == 11
replace region_txt = "South America" if region == 14
replace region_txt = "South Asia" if region == 17
replace region_txt = "South-East Asia" if region == 15
replace region_txt = "Sub-Saharian Africa" if region == 5 | region == 9 | region == 16 | region == 19
replace region_txt = "Western Europe" if region == 12 | region == 18 | region == 21
	collapse (count) eventid, by(region_txt iyear int_misc)
    replace int_misc=3 if int_misc==.
    reshape wide eventid, i(region_txt iyear) j(int_misc)
    drop eventid3
    rename eventid0 domestic
    rename eventid1 international
    label var domestic "Domestic (left scale)"
    label var international "International (right scale)"
    format domestic international %4.0f
egen region = group(region_txt)
    xtset region iyear 
*    twoway (tsline domestic, yaxis(1))  (tsline international, yaxis(2))
*tab region iyear
*, by(region_txt, rescale note(""))
     twoway (tsline domestic, yaxis(1))  (tsline international, yaxis(2)) , ///
        ylabel(#2) ylabel(#2, axis(2)) by(region_txt, rescale note("")) ///
         xla(1970(20)2018) ytitle("Terrorist events") xtitle("Year") scheme(s1mono) subtitle(, nobox)
    graph export "$results/Graph_terror_geo_int.eps", replace
restore




***** FIGURE 2 - TREND OF TRUST *****

preserve

    kountry cntcode, from(iso3n) geo(un)
    rename GEO area
    drop NAMES_STD 

    replace area = "Europe" if country_txt == "East Germany (GDR)"
    replace area = "Europe" if country_txt == "Kosovo"
    replace area = "Europe" if country_txt == "Montenegro"
    replace area = "Europe" if country_txt == "Serbia"
    replace area = "Asia"   if country_txt == "Taiwan"
    replace area = "Europe" if country_txt == "West Germany (FRG)"
    replace area = "Asia"   if country_txt == "Vietnam"
    
    replace area = "Asia" if area == "Oceania"
    replace area = "Asia and Oceania" if area == "Asia"
    
    * Move US and Canada to Europe (eliminare le 4 righe per tornare alla versione precedente)
    replace area = "Europe" if country_txt == "Canada"
    replace area = "Europe" if country_txt == "United States"

    replace area = "Europe and North America" if area == "Europe"
    replace area = "South America" if area == "Americas"
    
    tab trust
    tab trust if $missing
    tab trust if $missing & polity_contemp > 0
    tab trust if $missing & polity_contemp <= 0
    *table wave, c(mean trust)
    *table region_wvs, c(mean trust)
    *table area if $missing, c(mean trust)
    *table area wave, c(mean trust) row col format(%3.2f)
    *table country_txt wave, c(mean trust) row col format(%3.2f)
    bys area wave: tab trust if $missing

	collapse (mean) trust, by(area wave) // added
    tab area, gen(area_num)
    egen area_bis = group(area)
    xtset area_bis wave 
    format trust %9.2f
    label def waves 1 "1981-1984" 2 "1990-1993" 3 "1995-1998" ///
        4 "1999-2004" 5 "2005-2009" 6 "2010-2014" 7 "2017-2020"
    label val wave waves
    tsline trust if wave >= 1 & wave <= 7, by(area, note("")) ylabel(0 0.25 0.5) ///
        tlabel(, valuelabel angle(45)) xlabel(1 2 3 4 5 6 7) ///
        ytitle("Trust") xtitle("Wave") scheme(s1mono) subtitle(, nobox)
restore



*************************************
************ REGRESSIONS ************
*************************************

*** SAMPLE DEFINITION ***

global  missing      "trust_1000 != . & events_tot_15_25!=. & female!=. & age!=. & age2!=. & employ!=. & educ_index!=. & n_child != . & marstat != . & birth_year != . & int_pol != . & import_relig_dummy != . & gdp_growth != . & polity_15_25 != ."

global  ind_cntrls   female age age2 employ i.educ_index i.marstat n_child
global  inter_cntrls int_pol import_relig_dummy
global  macro_cntrls gdp_growth
global  hexog_cntrls female age age2

gen events_tot_26over=events_tot_26plus-events_tot_t1 

label var events_tot_26over "Terrorist events (26+)"



*** TABLE 3, BASELINE LINEAR PROBABILITY MODEL ***

reg     trust_1000 events_tot_15_25 ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
estadd  beta
est sto y_baseline1

reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
estadd  beta
est sto y_baseline2

reg     trust_1000 events_tot_15_25 $ind_cntrls $inter_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
estadd  beta
est sto y_baseline3

reg     trust_1000 events_tot_15_25 $ind_cntrls $inter_cntrls $macro_cntrls polity_contemp ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
estadd  beta
est sto y_baseline4

reg     trust_1000 events_tot_15_25 $ind_cntrls $inter_cntrls polity_contemp gdp_growth_1525 ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
estadd  beta
est sto y_baseline5









*** TABLE 4, DIFFERENT TERRORISM INDICATORS ***


* Number of events with at least 1 death
reg     trust_1000 events_kills_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices2

* Number of events with at least 10 deaths
reg     trust_1000 events_kills_10_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices3

* Number of events with at least 50 deaths
reg     trust_1000 events_kills_50_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices4

* Number of casualties
reg     trust_1000 nkill_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices5

* Sum of events and casualties
reg     trust_1000 terrindex_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices6

* Property damages
reg     trust_1000 property_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices7

* Major property damages
reg     trust_1000 damage_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_indices8





*** TABLE 5, EVENTS IN THE PREVIOUS YEAR ***

label var property_t1 "Events resulting in property damage"
label var damage_t1 "Events with at least major damage (> 1 mln dollars)"

* Number of events in the previous year
reg     trust_1000 events_tot_15_25 events_tot_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart1

* Number of casualties in the previous year
reg     trust_1000 events_tot_15_25 nkill_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart2

* Number of events with at least 1 death in the previous years
reg     trust_1000 events_tot_15_25 events_kills_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart3

* Number of events with at least 10 deaths in the previous years
reg     trust_1000 events_tot_15_25 events_kills_10_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart4

* Number of events with at least 50 deaths in the previous years
reg     trust_1000 events_tot_15_25 events_kills_50_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart5

* Property damages in the previous years
reg     trust_1000 events_tot_15_25 property_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart6

* Major property damages in the previous years
reg     trust_1000 events_tot_15_25 damage_t1 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto yeart7






*** TABLE 6, DIFFERENT DEMOCRACY LEVELS ***

* Dummy definition
sum polity_15_25 if $missing 
global mean_polity=r(mean)
gen dumpolity_15_25= (polity_15_25>=5) if !missing(polity_15_25)
label var dumpolity_15_25 "Democracy"
label def dumpol 1 "Democracy" 0 "Non democracy"
label val dumpolity_15_25 dumpol

* with democracy level
reg     trust_1000 events_tot_15_25 polity_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_polity1

* democracy level interacted with events
reg     trust_1000 c.events_tot_15_25##c.polity_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_polity2

    *** R1, minor 8 ***
reg     trust_1000 c.events_tot_15_25##i.dumpolity_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_polity2bis

* only non-democracies
reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing & polity_15_25 < 5, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_polity3

* only democracies
reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing & polity_15_25 >= 5, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_polity4




*** TABLE 7, DIFFERENT PERPETRATORS ***

* Only domestic attacks
reg     trust_1000 domestic_misc_15_25 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year /// 
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_perpr1

* Only international attacks
reg     trust_1000 international_misc_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_perpr2

* Domestic attacks interacted with democracy
reg     trust_1000 c.domestic_misc_15_25#i.dumpolity_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_perpr3

* International attacks interacted with democracy
reg     trust_1000 c.international_misc_15_25#i.dumpolity_15_25 $hexog_cntrls ///
		i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
		if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_perpr4



*** TABLE 8, EFFECT OF CONFLICTS ***

* Conflicts 15-25
reg     trust_1000 events_tot_15_25 conflict_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_conflict1

* Ever experienced a conflict
reg     trust_1000 events_tot_15_25 conflict_all $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_conflict2

* Only individuals who ever experienced a conflict
reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing & conflict_all == 1, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_conflict3

* Only individuals who never experienced a conflict
reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing & conflict_all == 0, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_conflict4




*** TABLE 9, BASELINE LINEAR PROBABILITY MODEL WITH RANDOM ASSIGNMENT ACROSS COUNTRIES (AT INDIVIDUAL LEVEL) ***

version 15

preserve

keep if $missing

set seed 30102020
shufflevar events_tot_15_25, cluster(birth_year)
table birth_year, c(mean events_tot_15_25 n events_tot_15_25 mean events_tot_15_25_shuffled n events_tot_15_25_shuffled)

sort birth_year
list birth_year events_tot_15_25 events_tot_15_25_shuffled in 1/20

label var events_tot_15_25_shuffled "Terrorist events (15-25), randomized (country, individual)"

reg     trust_1000 events_tot_15_25_shuffled $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_shuff1r

label var events_tot_15_25_shuffled "Terrorist events (15-25), randomized"

restore




***	TABLE A1, MODEL WITH INCOME ***

reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.income_scale i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto inc2






***	TABLE A2, BASELINE PROBIT MODEL ***

preserve 

replace events_tot_15_25 = events_tot_15_25 / 1000

probit  trust events_tot_15_25 ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
estadd	margins, dydx(events_tot_15_25) post
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_probit1

probit  trust events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
estadd	margins, dydx(events_tot_15_25) post
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto y_probit2


restore




***	TABLE A3, ALTERNATIVE CLUSTERS ***

egen cntbirth = group(cntcode birth_year)
egen cntyear  = group(cntcode year)
	
reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto altclust1

reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntbirth)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto altclust2

reg     trust_1000 events_tot_15_25 $hexog_cntrls ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing, cluster(cntyear)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto altclust3






*** FIGURE 3 ***

global  selection_age   events_tot_0_14 != . & events_tot_15_19!=. & events_tot_20_25!=. & events_tot_0_25 !=. & events_tot_15_25 !=. & events_tot_15plus !=.  & events_tot_26plus!=.

sum events_tot_15_25 if $missing & $selection_age
global sda_15_25 = r(sd)
sum events_tot_0_14 if $missing & $selection_age
global sda_0_14 = r(sd)
sum events_tot_0_25 if $missing & $selection_age
global sda_0_25 = r(sd)
sum events_tot_15plus if $missing & $selection_age
global sda_15plus = r(sd)
sum events_tot_26plus if $missing & $selection_age
global sda_26plus = r(sd)
sum events_tot_15_19 if $missing & $selection_age
global sda_15_19 = r(sd)
sum events_tot_20_25 if $missing & $selection_age 
global sda_20_25 = r(sd)

* 0-4
reg     trust_1000 events_tot_0_4 events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year   ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_0_4

* 5-9
reg     trust_1000 events_tot_5_9 events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year   ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_5_9

* 10-14
reg     trust_1000 events_tot_10_14 events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year   ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_10_14

* 15-19
reg     trust_1000 events_tot_15_19 events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_15_19

* 20-25
reg     trust_1000 events_tot_20_25 events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_20_25

* 26+
reg     trust_1000  events_tot_26over events_tot_t1 $hexog_cntrls /// $ind_cntrls $inter_cntrls $macro_cntrls  ///
        i.year i.cntcode i.birth_year i.cntcode#c.birth_year ///
        if $missing & $selection_age, cluster(cntcode)
unique 	cntcode if e(sample)
estadd  scalar cnt r(unique)
unique 	wave if e(sample)
estadd  scalar wave r(unique)
est sto r1_maj2_age_26over



coefplot r1_maj2_age_0_4 r1_maj2_age_5_9 r1_maj2_age_10_14 r1_maj2_age_15_19 r1_maj2_age_20_25 r1_maj2_age_26over, keep(events_tot_0_4 events_tot_5_9 events_tot_10_14 events_tot_15_19 events_tot_20_25 events_tot_26over) vertical legend(off) coeflabels(events_tot_0_4 = "0-4" events_tot_5_9 = "5-9" events_tot_10_14 = "10-14" events_tot_15_19 = "15-19" events_tot_20_25 = "20-25" events_tot_26over = "26+") xtitle("Age") yline(0) msymbol(0) mcolor(gs4) ciopts(color(gs4)) scheme(s2mono)





